﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace SelfService.DataAccess.Migrations
{
    public partial class 更新日志 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysOperators_SysClients_ClientID",
                table: "SysOperators");

            migrationBuilder.RenameColumn(
                name: "ClientID",
                table: "SysOperators",
                newName: "ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_SysOperators_ClientID",
                table: "SysOperators",
                newName: "IX_SysOperators_ClientId");

            migrationBuilder.AlterColumn<Guid>(
                name: "ClientId",
                table: "SysOperators",
                type: "char(36)",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                collation: "ascii_general_ci",
                oldClrType: typeof(Guid),
                oldType: "char(36)",
                oldNullable: true)
                .OldAnnotation("Relational:Collation", "ascii_general_ci");

            migrationBuilder.CreateTable(
                name: "SysCardType",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Name = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SysClientID = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysCardType", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysCardType_SysClients_SysClientID",
                        column: x => x.SysClientID,
                        principalTable: "SysClients",
                        principalColumn: "ID");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SysPayType",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Name = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SysClientID = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysPayType", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysPayType_SysClients_SysClientID",
                        column: x => x.SysClientID,
                        principalTable: "SysClients",
                        principalColumn: "ID");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_SysCardType_SysClientID",
                table: "SysCardType",
                column: "SysClientID");

            migrationBuilder.CreateIndex(
                name: "IX_SysPayType_SysClientID",
                table: "SysPayType",
                column: "SysClientID");

            migrationBuilder.AddForeignKey(
                name: "FK_SysOperators_SysClients_ClientId",
                table: "SysOperators",
                column: "ClientId",
                principalTable: "SysClients",
                principalColumn: "ID",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysOperators_SysClients_ClientId",
                table: "SysOperators");

            migrationBuilder.DropTable(
                name: "SysCardType");

            migrationBuilder.DropTable(
                name: "SysPayType");

            migrationBuilder.RenameColumn(
                name: "ClientId",
                table: "SysOperators",
                newName: "ClientID");

            migrationBuilder.RenameIndex(
                name: "IX_SysOperators_ClientId",
                table: "SysOperators",
                newName: "IX_SysOperators_ClientID");

            migrationBuilder.AlterColumn<Guid>(
                name: "ClientID",
                table: "SysOperators",
                type: "char(36)",
                nullable: true,
                collation: "ascii_general_ci",
                oldClrType: typeof(Guid),
                oldType: "char(36)")
                .OldAnnotation("Relational:Collation", "ascii_general_ci");

            migrationBuilder.AddForeignKey(
                name: "FK_SysOperators_SysClients_ClientID",
                table: "SysOperators",
                column: "ClientID",
                principalTable: "SysClients",
                principalColumn: "ID");
        }
    }
}
